package com.qf.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.entity.TbCourse;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 王希卓
 * @Date 2023/7/17 14:21
 */
public interface CourseDao extends BaseMapper<TbCourse> {
    /**
     * 查询所有课程
     * @param start
     * @param size
     * @param keyword
     * @return
     */
    @Select("select c.*,t.type_name,ta.teacher_name from tb_course c ,tb_type t ,tb_teacher ta where c.type_id=t.type_id and c.teacher_id=ta.teacher_id and c.course_name like concat('%',#{param3},'%') limit #{param1},#{param2}")
    List<TbCourse> selectAll(int start, int size, String keyword);

    /**
     * 通过分类查询课程
     * @param start
     * @param size
     * @param typeId
     * @return
     */
    @Select("select c.*,t.type_name,ta.teacher_name from tb_course c ,tb_type t ,tb_teacher ta where c.type_id=t.type_id and c.teacher_id=ta.teacher_id and c.type_id=#{param3} and c.course_name like concat('%',#{param4},'%') limit #{param1},#{param2}")
    List<TbCourse> selectByType(int start, int size, int typeId,String keyword);

    /**
     * 通过老师id查询课程
     * @param teacherId
     * @return
     */
    @Select("select c.*,t.type_name,te.teacher_name from tb_course c ,tb_type t,tb_teacher te where c.teacher_id=te.teacher_id and c.type_id=t.type_id and c.teacher_id=#{teacherId}")
    List<TbCourse> selectByTeacherId(int teacherId);

    //通过教师id条件查询课程后模糊查询
    @Select("select c.*,t.type_name,te.teacher_name from tb_course c ,tb_type t,tb_teacher te where c.teacher_id=te.teacher_id and c.type_id=t.type_id and c.teacher_id=#{teacherId} and c.course_name like concat('%',#{keyword},'%')")
    List<TbCourse> selectByTeacherIdTeacherName(String keyword,Integer teacherId);
}
